{
  LX Particle module

  Based on modo's SDK lxparticle.h which is:

  Copyright (c) 2008-2012 Luxology LLC

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.   Except as contained
  in this notice, the name(s) of the above copyright holders shall not be
  used in advertising or otherwise to promote the sale, use or other dealings
  in this Software without prior written authorization.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
}

{
  Copyright (c) 2012 David Ballesteros and Jameel Halabi

  This unit is part of the BLAISEmodo wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit Lx_Particle;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result, Lx_VMath;

const
  LXi_PFILT_FRAME          =  0;
  LXi_PFILT_RUN            =  1;
  LXi_PFILT_PARTICLE       =  2;
  LXi_PFILT_NEW_PARTICLE   =  3;

  LXsPARTICLEATTR_SEED     = 'seed'  ;
  LXsPARTICLEATTR_USEPOL   = 'usePol';
  LXsPARTICLEATTR_UPAXIS   = 'upAxis';
  LXsPARTICLEATTR_DEFORM   = 'deform';

  LXsP_DYNA_FORCE          = 'dynaForce';

  LXs_FX_FORCE_AMP         = 'forceAmplitude';
  LXs_FX_FORCE_DIR         = 'forceDirection';
  LXs_FX_FORCE_DRAG        = 'forceDrag'     ;

  LXsP_ANIM_DEFORM         = 'animDeform';

  LXs_FX_DEFORM_AMP        = 'deformAmplitude';

  LXsP_SAMPLE_FALLOFF      = 'sampleFalloff';

  LXs_FX_FALLOFF_VALUE     = 'falloffValue';

  LXsPKG_REPLICATOR        = 'pkg.replicator';

  LXs_PKG_IS_REPLICATOR    = '-';

  LXu_PARTICLEITEM         = '{BA13DD5D-5093-4D0D-BEFE-119AD4F1FACB}';
  LXu_REPLICATORENUMERATOR = '{01EC90A9-924F-4475-BA6A-FFF8A2691CD5}';
  LXu_PARTICLEEVALFRAME    = '{1AC26263-A422-4B17-A929-2F616037754F}';
  LXu_PARTICLEFILTER       = '{04A3C0C5-1C5C-43F5-8559-ACF3BAE79C0B}';
  LXu_PARTICLEFILTERITEM   = '{EF31BA82-8EC4-46C5-9A28-2785BE78D861}';

type
  PLXpDynaForce = ^LXpDynaForce;
  LXpDynaForce  = record
    Dir       : LXtFVector;
    Amplitude : Single    ;
    Drag      : Single    ;
  end;

  PLXpAnimDeform = ^LXpAnimDeform;
  LXpAnimDeform  = record
    Dir       : LXtFVector;
    Amplitude : Single    ;
  end;

  PLXpSampleFalloff = ^LXpSampleFalloff;
  LXpSampleFalloff = record
    Value : Single;
  end;

  ILxParticleItem = interface
  [LXu_PARTICLEITEM]
    function Prepare (    Eval  : IUnknown;
                          Index : PUInt32 ) : LxResult;
    function Evaluate(    Attr  : IUnknown;
                          Index : UInt32  ;
                      out VObj            ) : LxResult;
  end;

  ILxReplicatorEnumerator = interface
  [LXu_REPLICATORENUMERATOR]
    function  Enumerate  (    Visitor    : IUnknown ;
                              Chan       : IUnknown ;
                              LocalXform : Integer  ) : LxResult;
    function  Item       (out VObj                  ) : LxResult;
    procedure Position   (    Pos        : LXtVector)           ;
    procedure Orientation(    Mx         : LXtMatrix)           ;
    function  ID                                      : Single  ;
    function  Dissolve                                : Single  ;
  end;

  ILxParticleEvalFrame = interface
  [LXu_PARTICLEEVALFRAME]
    function VertexDescription                          : IUnknown;
    function MaxCount                                   : UInt32  ;
    function AliveCount                                 : UInt32  ;
    function AddParticle      (const State  : PSingle ;
                                     Index  : PUInt32 ) : LxResult;
    function KillParticle     (      Index  : UInt32  ) : LxResult;
    function IsAlive          (      Index  : UInt32  ) : UInt32  ;
    function GetVector        (      Index  : UInt32  ;
                                     Vector : PSingle ) : LxResult;
    function SetVector        (      Index  : UInt32  ;
                               const Vector : PSingle ) : LxResult;
    function AliveRun         (      First  : UInt32  ;
                               const Alive  : PPUInt32;
                                     Count  : PUInt32 ) : LxResult;
    function VectorRun        (      First  : UInt32  ;
                                     Values : PPSingle;
                                     Count  : PUInt32 ) : LxResult;
  end;

  ILxParticleFilter = interface
  [LXu_PARTICLEFILTER]
    function  Vertex                         : IUnknown;
    function  &Type                          : UInt32  ;
    function  Initialize(Vertex_ : IUnknown;
                         Frame   : IUnknown;
                         Time    : Double  ) : LxResult;
    function  Step      (Other   : IUnknown;
                         DT      : Double  ) : LxResult;
    procedure Cleanup                        ;
    function  Frame                          : LxResult;
    function  Run       (Values  : PPSingle;
                         Count   : UInt32  ) : LxResult;
    function  Particle  (Vertex_ : PSingle ) : LxResult;
  end;

  ILxParticleFilterItem = interface
  [LXu_PARTICLEFILTERITEM]
    function Prepare (    Eval  : IUnknown;
                          Index : PUInt32 ) : LxResult;
    function Evaluate(    Attr  : IUnknown;
                          Index : UInt32  ;
                      out VObj            ) : LxResult;
  end;

implementation

end.

